package com.example.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: Jason
 * @ClassName: RespBean
 * @Description: 公共返回对象
 * @Package：com.example.seckill.vo
 * @Project：seckill
 * @name：RespBean
 * @Filename：RespBean
 **/
@Data//生成实体属性对应get、set方法
@NoArgsConstructor//无参构造
@AllArgsConstructor//全参构造
public class RespBean {
    private long code;
    private String message;
    private Object obj;

    //成功返回结果
    public static RespBean success(RespBeanEnum respBeanEnum){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMessage(),null);
    }
    public static RespBean success(RespBeanEnum respBeanEnum,Object obj){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMessage(),obj);
    }
    public static RespBean success(Object obj){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMessage(),obj);
    }

    //失败返回结果
    public static RespBean error(RespBeanEnum respBeanEnum){
        return new RespBean(RespBeanEnum.ERROR.getCode(),RespBeanEnum.ERROR.getMessage(),null);
    }
    public static RespBean error(RespBeanEnum respBeanEnum,Object obj){
        return new RespBean(RespBeanEnum.ERROR.getCode(),RespBeanEnum.ERROR.getMessage(),obj);
    }
    public static RespBean error(Object obj){
        return new RespBean(RespBeanEnum.ERROR.getCode(),RespBeanEnum.ERROR.getMessage(),obj);
    }


}
